import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '../vuex/store'
Vue.use(VueRouter)

import home from '../components/page/home.vue'
import proList from '../components/page/proList.vue'
import upload from '../components/page/upload.vue'
import editPro from '../components/page/editPro.vue'
import user from '../components/page/user.vue'
import check from '../components/page/check.vue'
import result from '../components/page/result.vue'
import detail from '../components/page/detail.vue'
import userinfo from '../components/page/userinfo.vue'




const router = new VueRouter({
	mode: 'hash',
	base: __dirname,
	routes: [
		{
			path: '/',
			component: home
		},
		{
			path: '/proList/:id',
			component: proList
		},
		{
			path: '/user',
			component: user
		},
		{
			path: '/upload',
			component: upload
		},
		{
			path: '/editPro',
			component: editPro
		},
		{
			path: '/detail',
			component: detail
		},
		{
			path: '/userinfo',
			component: userinfo
		},
		,
		{
			path: '/result',
			component: result
		},
		{
			path: '/check',
			component: check
		},

	]
})
//每次进入新组件后滚动条回到顶部
router.beforeEach(function (to, from, next) {
	// if (to.path == '/' || to.path == '/game' || to.path == '/newmedia' || to.path == '/cartoon' || to.path == '/detail') {
	// 	console.log(to.path)
	// 	next();
	// }
	// else if (!sessionStorage.getItem('token')) {
	// 	router.push('/')
	// }

	next();

});


export default router;